// AIP插件的动作捕捉事件。
function HWPostil1_JSNotifyBeforeAction(lActionType, lType, strName, strValue) {
    //表单的页面属性字段是包含有Page页信息的故此判断。
    if (lActionType == 7) {
        if (strName.substr(0, 11) == "Page1.popup") {
            // 加载项目信息
            loadProjectItem(strName);
        } else if (strName == "Page1.total_day") {
            // 计算日期差
            subDate();
        } else if (strName == "Page1.xmlzh") {
            // 加载项目编号
            loadProjectLzh(strName);
        }
    }
}

// AIP值变化触发事件
function HWPostil1_NotifyChangeValue(nodeName, nodeValue) {
    var flowid = mini.getByName("flowid").getValue();
    //用于取代flowid
    var flowVersion = mini.getByName("flowVersion").getValue();
    if (flowid == "flow_bjflfybx" || flowid == "flow_hnflfybx") {
        //北京/湖南福利费用报销特殊处理
        dealbjflfybx(nodeName, flowid);
    } else if (flowid == "flow_zcgzsq") {
        // 固定资产购置特殊处理
        dealzcgzsq(nodeName);
    } else if (flowid == "flow_zzcg") {
        // 终止采购特殊处理
        dealzzcg(nodeName);
    } else if (flowid == "flow_chbf") {
        // 存货报废特殊处理
        dealchbf(nodeName);
    } else if (flowid == "flow_jzbyj" || flowid == "flow_hnjzbyj") {
        // 借支备用金特殊处理
        dealjzbyj(nodeName);
    } else if (flowid == "flow_zply" || flowid == "flow_hnzply") {
        //支票领用的特殊处理(北京、湖南)
        dealzply(nodeName);
    } else if (flowid == "flow_clfybx" || flowid == "flow_hnclfybx") {
        // 差旅费报销的特殊处理(北京、湖南)
        dealclfybx(nodeName);
        // 差旅报销检查列表的特殊处理
        dealclfybxlb(nodeName);
    } else if (flowid == "flow_rcfybx" || flowid == "flow_hnrcfybx") {
        //日常费报销的特殊处理(北京/湖南)
        dealrcfybx(nodeName, flowid);
    } else if (flowid == "flow_dwfk" || flowid == "flow_hndwfk") {
        //对外付款审批单的特殊处理(北京、湖南，项目号手填)
        dealdwfkspd(nodeName);
    } else if (flowid == "flow_kjfp" || flowid == "flow_hnkjfp") {
        //发票开具审批单的特殊处理
        dealfpkjspd(nodeName);
    } else if (flowid == "flow_cgjhsq") {
        // 采购计划申请的特殊处理(北京、湖南)
        dealcgjhsq(nodeName);
    } else if (flowid == "flow_syqkh_xs" || flowid == "flow_syqkh") {
        //试用期考核
        dealsyqkh(nodeName);
    } else if (flowid == "flow_zhht" || flowid == "flow_qtht" || flowid == "flow_htgl") {
        dealhtje(nodeName);
    } else if (flowid == "flow_rlzyzgkh" || flowid == "flow_rlzyzpkh" || flowid == "flow_cxyfkh" ||
        flowid == "flow_cwjlkh" || flowid == "flow_cwzgkh" || flowid == "flow_fykjkh" ||
        flowid == "flow_zjgcskh" || flowid == "flow_swzykh" || flowid == "flow_xzzykh" ||
        flowid == "flow_cgzykh") {
        // 月度考核
        dealydkh(nodeName);
    }
}

// 月度考核特殊处理
function dealydkh(nodeName) {

    if (nodeName == "Page1.cdztcs" || nodeName == "Page1.kgtgcs" || nodeName == "Page1.wdkcs") {
        var value1 = AipObj.GetValueEx("Page1.cdztcs", 2, "", 0, "");
        var value2 = AipObj.GetValueEx("Page1.kgtgcs", 2, "", 0, "");
        var value3 = AipObj.GetValueEx("Page1.wdkcs", 2, "", 0, "");
        if (value1 != '') {
            if (value1 > 4) {
                value1 = (value1 - 4) * 3 + 4;
            }
        }
        if (value2 != '') {
            if (value2 >= 1 && value2 <= 2) {
                value2 = value2 * 20;
            } else if (value2 > 2) {
                value2 = 100;
            }
        }
        var v = value1 * 1 + value2 * 1 + value3 * 1;

        if (v != 0) {
            AipObj.SetValue("Page1.kqjf", v * -1);
        } else {
            AipObj.SetValue("Page1.kqjf", "");
        }
    }
    if (nodeName == "Page1.khdf") {
        var value1 = AipObj.GetValueEx("Page1.khdf", 2, "", 0, "");
        if (value1 == 0) {
            AipObj.SetValue("Page1.khdf", "");
        } else {
            if (value1 > 85) {
                AipObj.SetValue("Page1.khxs", 1);
            } else if (value1 > 75 && value1 <= 85) {
                AipObj.SetValue("Page1.khxs", 0.95);
            } else if (value1 > 65 && value1 <= 75) {
                AipObj.SetValue("Page1.khxs", 0.85);
            } else if (value1 >= 60 && value1 <= 65) {
                AipObj.SetValue("Page1.khxs", 0.8);
            } else {
                AipObj.SetValue("Page1.khxs", 0);
            }
        }
    }
    if (nodeName == "Page1.xzgljf") {
        var value1 = AipObj.GetValueEx("Page1.xzgljf", 2, "", 0, "");
        if (value1 > 0) {
            AipObj.SetValue("Page1.xzgljf", -value1);
        }
    }
}

// AIP表单的动作操作之后执行
function HWPostil1_NotifyAfterAction(lActionType, lType, strName, strValue) {
    // 5 盖章 3 删除节点(撤章)
    if (lActionType == 5 || lActionType == 3) {
        // 这里需要 延迟执行不然会导致签章显示不出来或者撤章失败 ，原因是签章，撤章都需要与签章服务器交互存在响应的时间差
        setTimeout("saveAIPForm(null)", 800);
    }
}

function dealbjflfybx(nodeName, flowid) {
    //原值保留小数点后两位
    if (nodeName == "Page1.money01" || nodeName == "Page1.money02" || nodeName == "Page1.money03" || nodeName == "Page1.money04" || nodeName == "Page1.money05"
        || nodeName == "Page1.money06" || nodeName == "Page1.money07" || nodeName == "Page1.money08" || nodeName == "Page1.money09"
        || nodeName == "Page1.money10" || nodeName == "Page1.money11" || nodeName == "Page1.money12") {
        getValueByNodeName(nodeName);
        var v1 = AipObj.GetValueEx("Page1.money01", 2, "", 0, "");
        var v2 = AipObj.GetValueEx("Page1.money02", 2, "", 0, "");
        var v3 = AipObj.GetValueEx("Page1.money03", 2, "", 0, "");
        var v4 = AipObj.GetValueEx("Page1.money04", 2, "", 0, "");
        var v5 = AipObj.GetValueEx("Page1.money05", 2, "", 0, "");
        var v6 = AipObj.GetValueEx("Page1.money06", 2, "", 0, "");
        var v7 = AipObj.GetValueEx("Page1.money07", 2, "", 0, "");
        var v8 = AipObj.GetValueEx("Page1.money08", 2, "", 0, "");
        var v9 = AipObj.GetValueEx("Page1.money09", 2, "", 0, "");
        var v10 = AipObj.GetValueEx("Page1.money10", 2, "", 0, "");
        var v11 = AipObj.GetValueEx("Page1.money11", 2, "", 0, "");
        var v12 = AipObj.GetValueEx("Page1.money12", 2, "", 0, "");

        var total = v1 * 100 + v2 * 100 + v3 * 100 + v4 * 100 + v5 * 100 + v6 * 100 + v7 * 100 + v8 * 100 + v9 * 100 + v10 * 100 + v11 * 100 + v12 * 100;
        returnAloneValue("Page1.pjhjje", total);
        var v13 = AipObj.GetValueEx("Page1.jkje", 2, "", 0, "");
        var hjje = total - v13 * 100;
        returnAloneValue("Page1.ybxhk", hjje);
    }
    if (nodeName == "Page1.jkje") {
        var v1 = AipObj.GetValueEx("Page1.pjhjje", 2, "", 0, "");
        var v2 = AipObj.GetValueEx("Page1.jkje", 2, "", 0, "");
        returnAloneValue(nodeName, v2 * 100);
        returnDifferenceValue(v1, v2, "Page1.ybxhk");
    }
    //应还款小数点默认
    if (nodeName == "Page1.ybxhk") {
        getValueByNodeName(nodeName);
    }
}

//赋与某节点值
function returnAloneValue(nodeName, v) {
    if (v != 0) {
        var v1 = Math.round(v) / 100;
        AipObj.SetValue(nodeName, v1.toFixed(2));
    } else {
        AipObj.SetValue(nodeName, "");
    }
}

//通过节点名取值再赋值（某个节点）
function getValueByNodeName(nodeName) {
    var v = AipObj.GetValueEx(nodeName, 2, "", 0, "");
    if (v != 0) {
        var v1temp = Math.round(v * 100) / 100;
        AipObj.SetValue(nodeName, v1temp.toFixed(2));
    } else {
        AipObj.SetValue(nodeName, "");
    }
}

//通过节点名取值再赋值给第三节点（两个节点之积）
function returnProductValue(nodeName1, nodeName2, nodeName3) {
    var v1 = AipObj.GetValueEx(nodeName1, 2, "", 0, "");
    var v2 = AipObj.GetValueEx(nodeName2, 2, "", 0, "");
    var total1 = (v1 * v2) * 100;
    if (total1 != 0) {
        var v3 = Math.round(total1) / 100;
        AipObj.SetValue(nodeName3, v3.toFixed(2));
    } else {
        AipObj.SetValue(nodeName3, "");
    }
}

//通过节点名取值再赋值给第三节点（两个节点之差）
function returnDifferenceValue(v1, v2, nodeName3) {
    var total = v1 * 100 - v2 * 100;
    if (total != 0) {

        var totalMoney = Math.round(total) / 100;
        AipObj.SetValue(nodeName3, totalMoney.toFixed(2));
    } else {
        mini.alert("已报销(还款)金额不能为0元");
    }
}

function dealzcgzsq(nodeName) {
    //原值保留小数点后两位
    if (nodeName == "Page1.dj01") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj02") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj03") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj04") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj05") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj06") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj07") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj08") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj09") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj10") {
        getValueByNodeName(nodeName);
    }
    // 预计总价计算
    if (nodeName == "Page1.zj01" || nodeName == "Page1.sl01" || nodeName == "Page1.dj01") {
        returnProductValue("Page1.sl01", "Page1.dj01", "Page1.zj01");
    } else if (nodeName == "Page1.zj02" || nodeName == "Page1.sl02" || nodeName == "Page1.dj02") {
        returnProductValue("Page1.sl02", "Page1.dj02", "Page1.zj02");
    } else if (nodeName == "Page1.zj03" || nodeName == "Page1.sl03" || nodeName == "Page1.dj03") {
        returnProductValue("Page1.sl03", "Page1.dj03", "Page1.zj03");
    } else if (nodeName == "Page1.zj04" || nodeName == "Page1.sl04" || nodeName == "Page1.dj04") {
        returnProductValue("Page1.sl04", "Page1.dj04", "Page1.zj04");
    } else if (nodeName == "Page1.zj05" || nodeName == "Page1.sl05" || nodeName == "Page1.dj05") {
        returnProductValue("Page1.sl05", "Page1.dj05", "Page1.zj05");
    } else if (nodeName == "Page1.zj06" || nodeName == "Page1.sl06" || nodeName == "Page1.dj06") {
        returnProductValue("Page1.sl06", "Page1.dj06", "Page1.zj06");
    } else if (nodeName == "Page1.zj07" || nodeName == "Page1.sl07" || nodeName == "Page1.dj07") {
        returnProductValue("Page1.sl07", "Page1.dj07", "Page1.zj07");
    } else if (nodeName == "Page1.zj08" || nodeName == "Page1.sl08" || nodeName == "Page1.dj08") {
        returnProductValue("Page1.sl08", "Page1.dj08", "Page1.zj08");
    } else if (nodeName == "Page1.zj09" || nodeName == "Page1.sl09" || nodeName == "Page1.dj09") {
        returnProductValue("Page1.sl09", "Page1.dj09", "Page1.zj09");
    } else if (nodeName == "Page1.zj10" || nodeName == "Page1.sl10" || nodeName == "Page1.dj10") {
        returnProductValue("Page1.sl10", "Page1.dj10", "Page1.zj10");
    }
    // 合计总价
    if (nodeName == "hj" || nodeName == "Page1.zj01" || nodeName == "Page1.zj02" || nodeName == "Page1.zj03" || nodeName == "Page1.zj04" || nodeName == "Page1.zj05" || nodeName == "Page1.zj06" || nodeName == "Page1.zj07" || nodeName == "Page1.zj08" || nodeName == "Page1.zj09" || nodeName == "Page1.zj10") {
        var zj1 = AipObj.GetValueEx("Page1.zj01", 2, "", 0, "");
        var zj2 = AipObj.GetValueEx("Page1.zj02", 2, "", 0, "");
        var zj3 = AipObj.GetValueEx("Page1.zj03", 2, "", 0, "");
        var zj4 = AipObj.GetValueEx("Page1.zj04", 2, "", 0, "");
        var zj5 = AipObj.GetValueEx("Page1.zj05", 2, "", 0, "");
        var zj6 = AipObj.GetValueEx("Page1.zj06", 2, "", 0, "");
        var zj7 = AipObj.GetValueEx("Page1.zj07", 2, "", 0, "");
        var zj8 = AipObj.GetValueEx("Page1.zj08", 2, "", 0, "");
        var zj9 = AipObj.GetValueEx("Page1.zj09", 2, "", 0, "");
        var zj10 = AipObj.GetValueEx("Page1.zj10", 2, "", 0, "");
        var totalhj = (zj1 * 100) + (zj2 * 100) + (zj3 * 100) + (zj4 * 100) + (zj5 * 100) + (zj6 * 100) + (zj7 * 100) + (zj8 * 100) + (zj9 * 100) + (zj10 * 100);
        returnAloneValue("Page1.hj", totalhj);
    }
}

// 终止采购特殊处理
function dealzzcg(nodeName) {
    //原值保留小数点后两位
    if (nodeName == "Page1.dj01") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj02") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj03") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj04") {
        getValueByNodeName(nodeName);
    }

    if (nodeName == "Page1.zj01" || nodeName == "Page1.sl01" || nodeName == "Page1.dj01") {
        returnProductValue("Page1.sl01", "Page1.dj01", "Page1.zj01");
    } else if (nodeName == "Page1.zj02" || nodeName == "Page1.sl02" || nodeName == "Page1.dj02") {
        returnProductValue("Page1.sl02", "Page1.dj02", "Page1.zj02");
    } else if (nodeName == "Page1.zj03" || nodeName == "Page1.sl03" || nodeName == "Page1.dj03") {
        returnProductValue("Page1.sl03", "Page1.dj03", "Page1.zj03");
    } else if (nodeName == "Page1.zj04" || nodeName == "Page1.sl04" || nodeName == "Page1.dj04") {
        returnProductValue("Page1.sl04", "Page1.dj04", "Page1.zj04");
    }

    if (nodeName == "hjje" || nodeName == "Page1.zj01" || nodeName == "Page1.zj02" || nodeName == "Page1.zj03" || nodeName == "Page1.zj04") {
        var zj1 = AipObj.GetValueEx("Page1.zj01", 2, "", 0, "");
        var zj2 = AipObj.GetValueEx("Page1.zj02", 2, "", 0, "");
        var zj3 = AipObj.GetValueEx("Page1.zj03", 2, "", 0, "");
        var zj4 = AipObj.GetValueEx("Page1.zj04", 2, "", 0, "");
        var totalhj = (zj1 * 100) + (zj2 * 100) + (zj3 * 100) + (zj4 * 100);
        returnAloneValue("Page1.hjje", totalhj);
    }
}

// 存货报废特殊处理
function dealchbf(nodeName) {
    //原值保留小数点后两位
    if (nodeName == "Page1.dj01") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj02") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj03") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj04") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj05") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj06") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj07") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj08") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj09") {
        getValueByNodeName(nodeName);
    }

    // 小计特殊处理
    if (nodeName == "Page1.xj01" || nodeName == "Page1.sl01" || nodeName == "Page1.dj01") {
        returnProductValue("Page1.sl01", "Page1.dj01", "Page1.xj01");
    } else if (nodeName == "Page1.xj02" || nodeName == "Page1.sl02" || nodeName == "Page1.dj02") {
        returnProductValue("Page1.sl02", "Page1.dj02", "Page1.xj02");
    } else if (nodeName == "Page1.xj03" || nodeName == "Page1.sl03" || nodeName == "Page1.dj03") {
        returnProductValue("Page1.sl03", "Page1.dj03", "Page1.xj03");
    } else if (nodeName == "Page1.xj04" || nodeName == "Page1.sl04" || nodeName == "Page1.dj04") {
        returnProductValue("Page1.sl04", "Page1.dj04", "Page1.xj04");
    } else if (nodeName == "Page1.xj05" || nodeName == "Page1.sl05" || nodeName == "Page1.dj05") {
        returnProductValue("Page1.sl05", "Page1.dj05", "Page1.xj05");
    } else if (nodeName == "Page1.xj06" || nodeName == "Page1.sl06" || nodeName == "Page1.dj06") {
        returnProductValue("Page1.sl06", "Page1.dj06", "Page1.xj06");
    } else if (nodeName == "Page1.xj07" || nodeName == "Page1.sl07" || nodeName == "Page1.dj07") {
        returnProductValue("Page1.sl07", "Page1.dj07", "Page1.xj07");
    } else if (nodeName == "Page1.xj08" || nodeName == "Page1.sl08" || nodeName == "Page1.dj08") {
        returnProductValue("Page1.sl08", "Page1.dj08", "Page1.xj08");
    } else if (nodeName == "Page1.xj09" || nodeName == "Page1.sl09" || nodeName == "Page1.dj09") {
        returnProductValue("Page1.sl09", "Page1.dj09", "Page1.xj09");
    }
    if (nodeName == "hj" || nodeName == "Page1.xj01" || nodeName == "Page1.xj02" || nodeName == "Page1.xj03" || nodeName == "Page1.xj04" || nodeName == "Page1.xj05" || nodeName == "Page1.xj06" || nodeName == "Page1.xj07" || nodeName == "Page1.xj08" || nodeName == "Page1.xj09") {
        var xj01 = AipObj.GetValueEx("Page1.xj01", 2, "", 0, "");
        var xj02 = AipObj.GetValueEx("Page1.xj02", 2, "", 0, "");
        var xj03 = AipObj.GetValueEx("Page1.xj03", 2, "", 0, "");
        var xj04 = AipObj.GetValueEx("Page1.xj04", 2, "", 0, "");
        var xj05 = AipObj.GetValueEx("Page1.xj05", 2, "", 0, "");
        var xj06 = AipObj.GetValueEx("Page1.xj06", 2, "", 0, "");
        var xj07 = AipObj.GetValueEx("Page1.xj07", 2, "", 0, "");
        var xj08 = AipObj.GetValueEx("Page1.xj08", 2, "", 0, "");
        var xj09 = AipObj.GetValueEx("Page1.xj09", 2, "", 0, "");
        var totalhj = (xj01 * 100) + (xj02 * 100) + (xj03 * 100) + (xj04 * 100) + (xj05 * 100) + (xj06 * 100) + (xj07 * 100) + (xj08 * 100) + (xj09 * 100)
        returnAloneValue("Page1.hj", totalhj);
    }
}

// 借支备用金特殊处理
function dealjzbyj(nodeName) {
    // 原值保留小数点后两位
    if (nodeName == "Page1.htid") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.ljyfje") {
        getValueByNodeName(nodeName);
    }
}

//支票领用的特殊处理(北京、湖南)
function dealzply(nodeName) {
    if (nodeName == "Page1.bclyje") {
        getValueByNodeName(nodeName);
    }
    // 原值保留小数点后两位
}

// 采购计划申请的特殊处理(北京、湖南)
function dealcgjhsq(nodeName) {
    // 原值保留小数点后两位
    if (nodeName == "Page1.dj01") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj02") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj03") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.dj04") {
        getValueByNodeName(nodeName);
    }

    if (nodeName == "Page1.dj01" || nodeName == "Page1.sl01") {
        returnProductValue("Page1.sl01", "Page1.dj01", "Page1.je01");
    } else if (nodeName == "Page1.dj02" || nodeName == "Page1.sl02") {
        returnProductValue("Page1.sl02", "Page1.dj02", "Page1.je02");
    } else if (nodeName == "Page1.dj03" || nodeName == "Page1.sl03") {
        returnProductValue("Page1.sl03", "Page1.dj03", "Page1.je03");
    } else if (nodeName == "Page1.dj04" || nodeName == "Page1.sl04") {
        returnProductValue("Page1.sl04", "Page1.dj04", "Page1.je04");
    }

    if (nodeName == "Page1.dj01" || nodeName == "Page1.dj02" || nodeName == "Page1.dj03" || nodeName == "Page1.dj04" || nodeName == "Page1.sl01" || nodeName == "Page1.sl02" || nodeName == "Page1.sl03" || nodeName == "Page1.sl04") {
        var v1 = AipObj.GetValueEx("Page1.je01", 2, "", 0, "");
        var v2 = AipObj.GetValueEx("Page1.je02", 2, "", 0, "");
        var v3 = AipObj.GetValueEx("Page1.je03", 2, "", 0, "");
        var v4 = AipObj.GetValueEx("Page1.je04", 2, "", 0, "");
        var total = v1 * 100 + v2 * 100 + v3 * 100 + v4 * 100;
        returnAloneValue("Page1.jehj", total);
    }
}

// 差旅费报销的特殊处理(北京、湖南)
function dealclfybx(nodeName) {
    // 原值保留小数点后两位
    if (nodeName == "Page1.clmoney1") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.clmoney2") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.clmoney3") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.clmoney4") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.clmoney5") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.clmoney6") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.clmoney7") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.clmoney8") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.clprice") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.clprice1") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.clprice2") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.clprice3") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.clhjje") {
        getValueByNodeName(nodeName);
    }

    if (nodeName == "Page1.clmoney1" || nodeName == "Page1.clmoney2" || nodeName == "Page1.clmoney3" || nodeName == "Page1.clmoney4" || nodeName == "Page1.clmoney5" || nodeName == "Page1.clmoney6" || nodeName == "Page1.clmoney7" || nodeName == "Page1.clmoney8") {

        var v1 = AipObj.GetValueEx("Page1.clmoney1", 2, "", 0, "");
        var v2 = AipObj.GetValueEx("Page1.clmoney2", 2, "", 0, "");
        var v3 = AipObj.GetValueEx("Page1.clmoney3", 2, "", 0, "");
        var v4 = AipObj.GetValueEx("Page1.clmoney4", 2, "", 0, "");
        var v5 = AipObj.GetValueEx("Page1.clmoney5", 2, "", 0, "");
        var v6 = AipObj.GetValueEx("Page1.clmoney6", 2, "", 0, "");
        var v7 = AipObj.GetValueEx("Page1.clmoney7", 2, "", 0, "");
        var v8 = AipObj.GetValueEx("Page1.clmoney8", 2, "", 0, "");

        var total = v1 * 100 + v2 * 100 + v3 * 100 + v4 * 100 + v5 * 100 + v6 * 100 + v7 * 100 + v8 * 100;
        returnAloneValue("Page1.clpjje", total);
        var v9 = AipObj.GetValueEx("Page1.clfjt", 2, "", 0, "");
        var hjje = Math.round(total * 100 + v9 * 100) / 100;
        returnAloneValue("Page1.clhjje", hjje);
    }

    if (nodeName == "Page1.clfjt" || nodeName == "Page1.clpjje") {
        var v1 = AipObj.GetValueEx("Page1.clpjje", 2, "", 0, "");
        var v2 = AipObj.GetValueEx("Page1.clfjt", 2, "", 0, "");
        var total = v1 * 100 + v2 * 100;
        getValueByNodeName("Page1.clpjje");
        getValueByNodeName("Page1.clfjt");
        returnAloneValue("Page1.clhjje", total);
    }
}

// 计算日期查
function subDate() {
    var end_date = AipObj.GetValueEx("Page1.end_date", 2, "", 0, "");
    var start_date = AipObj.GetValueEx("Page1.start_date", 2, "", 0, "");
    if (typeof end_date != "undefined" && end_date != null && end_date != "") {
        if (typeof start_date != "undefined" && start_date != null && start_date != "") {
            var v1 = AipObj.GetValueEx("Page1.start_date", 2, "", 0, "");
            var temp1 = v1.replace(/[年|月]/g, "-");
            v1 = temp1.replace(/日/g, "");
            var v2 = AipObj.GetValueEx("Page1.end_date", 2, "", 0, "");
            var temp2 = v2.replace(/[年|月]/g, "-");
            v2 = temp2.replace(/日/g, "");
            AipObj.SetValue("Page1.total_day", datedifference(v1, v2));
        }
    }
}

// 差旅报销检查列表的特殊处理
function dealclfybxlb(nodeName) {
    // 原值保留小数点后两位
    if (nodeName == "Page1.bxje01") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.bxje02") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.bxje03") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.bxje04") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.bxje05") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.bxje06") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.bxje07") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.bxje08") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.bxje09") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.bxje10") {
        getValueByNodeName(nodeName);
    }

    if (nodeName == "Page1.bxje01" || nodeName == "Page1.bxje02" || nodeName == "Page1.bxje03" || nodeName == "Page1.bxje04" || nodeName == "Page1.bxje05" || nodeName == "Page1.bxje06" || nodeName == "Page1.bxje07" || nodeName == "Page1.bxje08" || nodeName == "Page1.bxje09" || nodeName == "Page1.bxje10") {
        var v1 = AipObj.GetValueEx("Page1.bxje01", 2, "", 0, "");

        var v2 = AipObj.GetValueEx("Page1.bxje02", 2, "", 0, "");
        var v3 = AipObj.GetValueEx("Page1.bxje03", 2, "", 0, "");
        var v4 = AipObj.GetValueEx("Page1.bxje04", 2, "", 0, "");
        var v5 = AipObj.GetValueEx("Page1.bxje05", 2, "", 0, "");
        var v6 = AipObj.GetValueEx("Page1.bxje06", 2, "", 0, "");
        var v7 = AipObj.GetValueEx("Page1.bxje07", 2, "", 0, "");
        var v8 = AipObj.GetValueEx("Page1.bxje08", 2, "", 0, "");
        var v9 = AipObj.GetValueEx("Page1.bxje09", 2, "", 0, "");
        var v10 = AipObj.GetValueEx("Page1.bxje10", 2, "", 0, "");

        var total = v1 * 100 + v2 * 100 + v3 * 100 + v4 * 100 + v5 * 100 + v6 * 100 + v7 * 100 + v8 * 100 + v9 * 100 + v10 * 100;
        returnAloneValue("Page1.bxjexj", total);
    }
}

//日常费报销的特殊处理(北京/湖南)
function dealrcfybx(nodeName, flowid) {
    if (nodeName == "Page1.zdf") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.qyf") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.bgf") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.hyf") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.yhp") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.gdzc") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.jtf") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.txf") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.cwf") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.lqf") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.tcf") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.qtf") {
        getValueByNodeName(nodeName);
    }

    if (nodeName == "Page1.zdf" || nodeName == "Page1.qyf" || nodeName == "Page1.bgf" || nodeName == "Page1.hyf" || nodeName == "Page1.yhp"
        || nodeName == "Page1.gdzc" || nodeName == "Page1.jtf" || nodeName == "Page1.txf" || nodeName == "Page1.cwf"
        || nodeName == "Page1.lqf" || nodeName == "Page1.tcf" || nodeName == "Page1.qtf") {

        var v1 = AipObj.GetValueEx("Page1.zdf", 2, "", 0, "");
        var v2 = AipObj.GetValueEx("Page1.qyf", 2, "", 0, "");
        var v3 = AipObj.GetValueEx("Page1.bgf", 2, "", 0, "");
        var v4 = AipObj.GetValueEx("Page1.hyf", 2, "", 0, "");
        var v5 = AipObj.GetValueEx("Page1.yhp", 2, "", 0, "");
        var v6 = AipObj.GetValueEx("Page1.gdzc", 2, "", 0, "");
        var v7 = AipObj.GetValueEx("Page1.jtf", 2, "", 0, "");
        var v8 = AipObj.GetValueEx("Page1.txf", 2, "", 0, "");
        var v9 = AipObj.GetValueEx("Page1.cwf", 2, "", 0, "");
        var v10 = AipObj.GetValueEx("Page1.lqf", 2, "", 0, "");
        var v11 = AipObj.GetValueEx("Page1.tcf", 2, "", 0, "");
        var v12 = AipObj.GetValueEx("Page1.qtf", 2, "", 0, "");

        var total = v1 * 100 + v2 * 100 + v3 * 100 + v4 * 100 + v5 * 100 + v6 * 100 + v7 * 100 + v8 * 100 + v9 * 100 + v10 * 100 + v11 * 100 + v12 * 100;
        /* if (flowid == "flow_rcfybx") {
             returnAloneValue("Page1.pjjehjbj", total);
             var v13 = AipObj.GetValueEx("Page1.jkjebj", 2, "", 0, "");
             var hjje = total - v13 * 100;
             returnAloneValue("Page1.ybxbj", hjje);
         } else {
             returnAloneValue("Page1.pjjehjhn", total);
             var v13 = AipObj.GetValueEx("Page1.jkjehn", 2, "", 0, "");
             var hjje = total  - v13 * 100;
             returnAloneValue("Page1.ybxhn", hjje);
         }*/
        returnAloneValue("Page1.pjjehjhn", total);
        var v13 = AipObj.GetValueEx("Page1.jkjehn", 2, "", 0, "");
        var hjje = total - v13 * 100;
        returnAloneValue("Page1.ybxhn", hjje);
    }
    if (nodeName == "Page1.jkjebj") {
        var v1 = AipObj.GetValueEx("Page1.pjjehjbj", 2, "", 0, "");
        var v2 = AipObj.GetValueEx("Page1.jkjebj", 2, "", 0, "");
        returnAloneValue(nodeName, v2 * 100);
        returnDifferenceValue(v1, v2, "Page1.ybxbj");

    } else if (nodeName == "Page1.jkjehn") {
        var v1 = AipObj.GetValueEx("Page1.pjjehjhn", 2, "", 0, "");
        var v2 = AipObj.GetValueEx("Page1.jkjehn", 2, "", 0, "");
        returnAloneValue(nodeName, v2 * 100);
        returnDifferenceValue(v1, v2, "Page1.ybxhn");
    }

    //应还款小数点默认
    if (nodeName == "Page1.ybxbj") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.ybxhn") {
        getValueByNodeName(nodeName);
    }
}

//对外付款审批单的特殊处理(北京、湖南，项目号手填)
function dealdwfkspd(nodeName) {
    if (nodeName == "Page1.cghjje") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.ljyfje") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.bczfje") {
        getValueByNodeName(nodeName);
    }
}

function dealhtje(nodeName) {
    if (nodeName == "Page1.htje") {
        getValueByNodeName(nodeName);
    }
}

//试用期考核
function dealsyqkh(nodeName) {
    if (nodeName == "Page3.zhpjdf1") {
        var v1 = AipObj.GetValueEx("Page3.zhpjdf1", 2, "", 0, "");
        if (parseInt(v1) != 0) {
            var dj = dejs(parseInt(v1));
            AipObj.SetValue("Page3.khdj1", dj);
        }
    }
    if (nodeName == "Page4.zhpjdf2") {
        var v1 = AipObj.GetValueEx("Page4.zhpjdf2", 2, "", 0, "");
        if (parseInt(v1) != 0) {
            var dj = dejs(parseInt(v1));
            AipObj.SetValue("Page4.khdj2", dj);
        }
    }

    if (nodeName == "Page4.syqzhdf") {
        var v1 = AipObj.GetValueEx("Page4.syqzhdf", 2, "", 0, "");
        if (parseInt(v1) != 0) {
            var dj = dejs(parseInt(v1));
            AipObj.SetValue("Page4.syqzhdj", dj);
        }
    }
//试用期销售
    if (nodeName == "Page4.zhpjdf3") {
        var v1 = AipObj.GetValueEx("Page4.zhpjdf3", 2, "", 0, "");
        if (parseInt(v1) != 0) {
            var dj = dejs(parseInt(v1));
            AipObj.SetValue("Page4.khdj3", dj);
        }
    }

    if (nodeName == "Page5.syqzhdf") {
        var v1 = AipObj.GetValueEx("Page5.syqzhdf", 2, "", 0, "");
        if (parseInt(v1) != 0) {
            var dj = dejs(parseInt(v1));
            AipObj.SetValue("Page5.syqzhdj", dj);
        }
    }
}

/*
           zsjndf1
VD$kqdf1$+$zsjndf1$+$gzqkdf1$+$tdpz1$
VD$kqdf2$+$zsjndf2$+$gzqkdf2$+$tdpz2$
*/
function dejs(v) {
    var s = 'E';
    if (v >= 60 && v < 75) {
        s = 'D';
    } else if (v >= 75 && v < 85) {
        s = 'C';
    } else if (v >= 85 && v < 95) {
        s = 'B';
    } else if (v >= 95 && v <= 100) {
        s = 'A';
    }
    return s;
}

//发票开具审批单的特殊处理
function dealfpkjspd(nodeName) {
    // 原值保留小数点后两位
    if (nodeName == "Page1.kpprice") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.kpprice1") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.kpprice2") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.kpprice3") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.kpmoney") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.kpmoney1") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.kphtje") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.kpsum") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.kpsum1") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.kpsum2") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.kpsum3") {
        getValueByNodeName(nodeName);
    } else if (nodeName == "Page1.kpsum4") {
        getValueByNodeName(nodeName);
    }

    if (nodeName == "Page1.kpprice" || nodeName == "Page1.kpcount") {
        var v1 = AipObj.GetValueEx("Page1.kpprice", 2, "", 0, "");
        var c1 = AipObj.GetValueEx("Page1.kpcount", 2, "", 0, "");
        var sum1 = AipObj.GetValueEx("Page1.kpsum1", 2, "", 0, "");
        var sum2 = AipObj.GetValueEx("Page1.kpsum2", 2, "", 0, "");
        var sum3 = AipObj.GetValueEx("Page1.kpsum3", 2, "", 0, "");
        var sum = c1 * v1;
        var sum4 = Math.round(sum * 100 + sum1 * 100 + sum2 * 100 + sum3 * 100) / 100;
        returnAloneValue(sum, "Page1.kpsum");
        returnAloneValue(sum4, "Page1.kpsum4");
    }

    if (nodeName == "Page1.kpprice1" || nodeName == "Page1.kpcount1") {
        var v1 = AipObj.GetValueEx("Page1.kpprice1", 2, "", 0, "");
        var c1 = AipObj.GetValueEx("Page1.kpcount1", 2, "", 0, "");
        var sum = AipObj.GetValueEx("Page1.kpsum", 2, "", 0, "");
        var sum2 = AipObj.GetValueEx("Page1.kpsum2", 2, "", 0, "");
        var sum3 = AipObj.GetValueEx("Page1.kpsum3", 2, "", 0, "");
        var sum1 = c1 * v1;
        var sum4 = Math.round(sum * 100 + sum1 * 100 + sum2 * 100 + sum3 * 100) / 100;
        returnAloneValue(sum1, "Page1.kpsum1");
        returnAloneValue(sum4, "Page1.kpsum4");
    }

    if (nodeName == "Page1.kpprice2" || nodeName == "Page1.kpcount2") {
        var v1 = AipObj.GetValueEx("Page1.kpprice2", 2, "", 0, "");
        var c1 = AipObj.GetValueEx("Page1.kpcount2", 2, "", 0, "");
        var sum1 = AipObj.GetValueEx("Page1.kpsum1", 2, "", 0, "");
        var sum = AipObj.GetValueEx("Page1.kpsum", 2, "", 0, "");
        var sum3 = AipObj.GetValueEx("Page1.kpsum3", 2, "", 0, "");
        var sum2 = c1 * v1;
        var sum4 = Math.round(sum * 100 + sum1 * 100 + sum2 * 100 + sum3 * 100) / 100;
        returnAloneValue(sum2, "Page1.kpsum2");
        returnAloneValue(sum4, "Page1.kpsum4");
    }

    if (nodeName == "Page1.kpprice3" || nodeName == "Page1.kpcount3") {
        var v1 = AipObj.GetValueEx("Page1.kpprice3", 2, "", 0, "");
        var c1 = AipObj.GetValueEx("Page1.kpcount3", 2, "", 0, "");
        var sum1 = AipObj.GetValueEx("Page1.kpsum1", 2, "", 0, "");
        var sum2 = AipObj.GetValueEx("Page1.kpsum2", 2, "", 0, "");
        var sum = AipObj.GetValueEx("Page1.kpsum", 2, "", 0, "");
        var sum3 = c1 * v1;
        var sum4 = Math.round(sum * 100 + sum1 * 100 + sum2 * 100 + sum3 * 100) / 100;
        returnAloneValue(sum3, "Page1.kpsum3");
        returnAloneValue(sum4, "Page1.kpsum4");
    }

    if (nodeName == "Page1.kpsum" || nodeName == "Page1.kpsum1" || nodeName == "Page1.kpsum2" || nodeName == "Page1.kpsum3") {
        var sum = AipObj.GetValueEx("Page1.kpsum", 2, "", 0, "");
        var sum1 = AipObj.GetValueEx("Page1.kpsum1", 2, "", 0, "");
        var sum2 = AipObj.GetValueEx("Page1.kpsum2", 2, "", 0, "");
        var sum3 = AipObj.GetValueEx("Page1.kpsum3", 2, "", 0, "");
        var sum4 = Math.round(sum * 100 + sum1 * 100 + sum2 * 100 + sum3 * 100) / 100;
        returnAloneValue(sum4, "Page1.kpsum4");
    }

    if (nodeName == "Page1.kphtje" || nodeName == "Page1.kpsum4") {
        var v1 = AipObj.GetValueEx("Page1.kphtje", 2, "", 0, "");
        var v2 = AipObj.GetValueEx("Page1.kpsum4", 2, "", 0, "");
        if (v1 != 0 && v2 != 0) {
            var bfb = v2 / v1 * 10000;
            var fpbfb = Math.round(bfb) / 100;
            AipObj.SetValue("Page1.kphtbl", fpbfb.toFixed(2));
        } else {
            AipObj.SetValue("Page1.kphtbl", "");
        }
    }
}

// 计算日期差
function datedifference(sDate1, sDate2) {    //sDate1和sDate2是2006-12-18格式
    var dateTemp = sDate1.split("-");
    sDate1 = new Date(dateTemp[0], dateTemp[1] - 1, dateTemp[2]);
    dateTemp = sDate2.split("-");
    sDate2 = new Date(dateTemp[0], dateTemp[1] - 1, dateTemp[2]);
    var dateSpan, iDays;
    dateSpan = sDate2 - sDate1;
    dateSpan = Math.abs(dateSpan);
    iDays = Math.floor(dateSpan / (24 * 3600 * 1000));
    return iDays
}

// 加载项目信息
function loadProjectItem(strName) {
    var popField = strName.substr(6);
    mini.open({
        url: "/oa/grbg/popup-project/view?popField=" + popField,
        title: "项目信息",
        width: 600,
        height: 400,
        allowResize: false,
        showCloseButton: false,
        onload: function () {
            var iframe = this.getIFrameEl();
            var data = {popField: popField};
            iframe.contentWindow.SetData(data);
        },
        ondestroy: function (action) {
            if (action == "ok") {
                var iframe = this.getIFrameEl();
                var data = iframe.contentWindow.GetData(); // 跨页面传值
                data = mini.clone(data);
                AipObj.SetValue(strName, "");
                AipObj.SetValue(strName, data.project);
            }
        }
    });
}

// 加载项目列支号
function loadProjectLzh(strName) {
    var popField = strName.substr(6);
    mini.open({
        url: "/oa/grbg/popup-project/view?popField=" + popField,
        title: "项目信息",
        width: 600,
        height: 400,
        allowResize: false,
        showCloseButton: false,
        onload: function () {
            var iframe = this.getIFrameEl();
            var data = {popField: popField};
            iframe.contentWindow.SetData(data);
        },
        ondestroy: function (action) {
            if (action == "ok") {
                var iframe = this.getIFrameEl();
                var data = iframe.contentWindow.GetData(); // 跨页面传值
                data = mini.clone(data);
                AipObj.SetValue(strName, "");
                AipObj.SetValue(strName, data.bh);
            }
        }
    });
}

// 初始化AIP信息
function initAIP(editable, uneditable, option, formfields, loginUser) {
    // 禁用所有表单节点
    var NoteInfo;
    while (NoteInfo = AipObj.GetNextNote("sys_admin", 0, NoteInfo)) {
        AipObj.SetValue(NoteInfo, ":PROP::LABEL:3");
    }

    for (i = 0; i < editable.length; i++) {
        AipObj.SetValue(editable[i], ":PROP::LABEL:0");

    }
    for (i = 0; i < uneditable.length; i++) {
        AipObj.SetValue(uneditable[i], ":PROP::LABEL:3");

    }
    for (var key in option) {

        AipObj.SetValueEx(key, 43, 0, option[key]);

    }
    for (var key in formfields) {
        AipObj.SetValue(key, formfields[key]);
    }
    for (var key in loginUser) {
        AipObj.SetValue(key, loginUser[key]);
    }
}

// 打印表单
function printForm() {
    FilePrint(AipObj, 1);
}

//差旅费用单填报张数处理
function specialCount() {
    var flowid = mini.getByName("flowid").getValue();
    var preformMark = mini.getByName("preformMark").getValue();
    var preaipmarkName = mini.getByName("preaipmarkName").getValue();
    if (flowid == "flow_clfybx" || flowid == "flow_hnclfybx") {
        var count = 0;
        if (preformMark == "OA_CLFYBXD") {
            count++;
        }
    }
}

// 差旅费用报销需要核对金额是否正确
function specialFlow() {
    var flowid = mini.getByName("flowid").getValue();
    if (flowid == "flow_clfybx" || flowid == "flow_hnclfybx") {

        var v1 = AipObj.GetValueEx("Page1.clmoney1", 2, "", 0, "");
        var v2 = AipObj.GetValueEx("Page1.clmoney2", 2, "", 0, "");
        var v3 = AipObj.GetValueEx("Page1.clmoney3", 2, "", 0, "");
        var v4 = AipObj.GetValueEx("Page1.clmoney4", 2, "", 0, "");
        var v5 = AipObj.GetValueEx("Page1.clmoney5", 2, "", 0, "");
        var v6 = AipObj.GetValueEx("Page1.clmoney6", 2, "", 0, "");
        var v7 = AipObj.GetValueEx("Page1.clmoney7", 2, "", 0, "");
        var v8 = AipObj.GetValueEx("Page1.clmoney8", 2, "", 0, "");
        var total = v1 * 100 + v2 * 100 + v3 * 100 + v4 * 100 + v5 * 100 + v6 * 100 + v7 * 100 + v8 * 100;

        var v9 = AipObj.GetValueEx("Page1.clprice", 2, "", 0, "");
        var v10 = AipObj.GetValueEx("Page1.clprice1", 2, "", 0, "");
        var v11 = AipObj.GetValueEx("Page1.clprice2", 2, "", 0, "");
        var v12 = AipObj.GetValueEx("Page1.clprice3", 2, "", 0, "");
        var totalPrice = v9 * 100 + v10 * 100 + v11 * 100 + v12 * 100;

        var v13 = AipObj.GetValueEx("Page1.clpjje", 2, "", 0, "");

        var pjje = v13 * 100

        if (Math.round(total) == Math.round(pjje) && Math.round(totalPrice) == Math.round(pjje)) {
            return true;
        }
        return false;
    }
    // 其他流程
    return true;
}